package com.cxd.springcloud.controller;

import com.cxd.springcloud.service.PaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class PaymentController {

    @Autowired
    private PaymentService paymentService;

    @GetMapping("/payment/hystrix/sayHello/{id}")
    public String sayHelloOk(@PathVariable("id") Integer id) {
        return paymentService.sayHelloOk(id);
    }

    @GetMapping("/payment/hystrix/sayHello/timeOut/{id}")
    public String sayHelloTimeOut(@PathVariable("id") Integer id) {

        return paymentService.sayHelloTimeOut(id);
    }

    @GetMapping("/payment/circuit/{id}")
    public String paymentCircuitBreaker(@PathVariable("id") Integer id) {

        String result = paymentService.paymentCircuitBreaker(id);
        log.info("result:{} ",result);
        return result;
    }

}
